/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.sandrini.sandelivery.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sandrini.sandelivery.service.BlogService;
import com.sandrini.sandelivery.service.ChatService;
import com.sandrini.sandelivery.service.ContactService;
import com.sandrini.sandelivery.service.MenuService;
import com.sandrini.sandelivery.service.NoticeService;
import com.sandrini.sandelivery.service.PortfolioService;
import com.sandrini.sandelivery.service.ProductService;
import com.sandrini.sandelivery.service.ResourceService;
import com.sandrini.sandelivery.service.ServiceService;

/**
 * Web controller used when loading the index page.
 */
@Controller
public class PageController {

    @Autowired
    private MenuService menuService;

    @Autowired
    private NoticeService noticeService;

    @Autowired
    private ServiceService serviceService;

    @Autowired
    private PortfolioService portfolioService;

    @Autowired
    private BlogService blogService;

    @Autowired
    private ResourceService resourceService;

    @Autowired
    private ProductService productService;

    @Autowired
    private ChatService chatService;

    @Autowired
    private ContactService contactService;

    @RequestMapping(value = "/page")
    public void viewHome(Model model) {
        model.addAttribute("menus", menuService.getAllMenus());
        model.addAttribute("notices", noticeService.getAllNotices());
        model.addAttribute("services", serviceService.getAllServices());
        model.addAttribute("portfolio", portfolioService.getAllPortfolio());
        model.addAttribute("blog", blogService.getAllPosts());
        model.addAttribute("resources", resourceService.getAllResources());
        model.addAttribute("products", productService.getAllProducts());
        model.addAttribute("chats", chatService.getAllChats());
        model.addAttribute("contacts", contactService.getAllContacts());
    }
}
